package fun.yyds.controller.taos;

import fun.yyds.common.ResponseData;
import fun.yyds.entity.message.AiMsg;
import fun.yyds.entity.taos.dto.InitTaosDTO;
import fun.yyds.service.ai.AiService;
import fun.yyds.service.taos.TaosService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Tag(name = "5.Taos")
@RequestMapping("/taos")
public class TaosController {
    @Resource
    private TaosService taosService;


    @PostMapping("/init/taosdb")
    @ApiOperation("按EU初始化taosDB")
    public ResponseData initTaosDB(@RequestBody InitTaosDTO initTaosDTO) {
        initTaosDTO.setDbName(initTaosDTO.getDbName().toLowerCase());
        initTaosDTO.setStbName(initTaosDTO.getStbName().toLowerCase());
        boolean ok = taosService.initTaosDB(initTaosDTO);
        if (ok){
            return ResponseData.success();
        }else {
            return ResponseData.fail("Failed to create taos database");
        }

    }

}
